<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>najaxjs Source: najax-read.static.js</title>

	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">

	<link type="text/css" rel="stylesheet" href="styles/site.yeti.css">

</head>

<body>

<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container">
	<div class="navbar-header">
		<a class="navbar-brand" href="index.html">najaxjs</a>
		<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
        </button>
	</div>
	<div class="navbar-collapse collapse" id="topNavigation">
		<ul class="nav navbar-nav">
			
			<li class="dropdown">
				<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="$najax.html">$najax</a></li><li><a href="$najax.define.html">$najax.define</a></li><li><a href="$najax.history.html">$najax.history</a></li><li><a href="$najax@class.html">$najax@class</a></li><li><a href="$najax@ex.html">$najax@ex</a></li><li><a href="$najax@helper.html">$najax@helper</a></li><li><a href="$najax@read.html">$najax@read</a></li><li><a href="$najax@rlk.html">$najax@rlk</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="Linker.html">Linker</a></li><li><a href="Nx.html">Nx</a></li><li><a href="Pager.html">Pager</a></li><li><a href="Reflector.html">Reflector</a></li><li><a href="Relay.html">Relay</a></li><li><a href="RESTful.html">RESTful</a></li><li><a href="Singular.html">Singular</a></li><li><a href="Tx.html">Tx</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="tutorials.list.html" class="dropdown-toggle" data-toggle="dropdown">Tutorials<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="tutorial-demo-ui-ajax.html">demo-ui-ajax</a></li><li><a href="tutorial-najax-class.html">najax-class</a></li><li><a href="tutorial-najax-ex.html">najax-ex</a></li><li><a href="tutorial-najax-helper.html">najax-helper</a></li><li><a href="tutorial-najax-read.html">najax-read</a></li><li><a href="tutorial-relaylinker.html">relaylinker</a></li><li><a href="tutorial-rlk-standalone.html">rlk-standalone</a></li><li><a href="tutorial-static-history.html">static-history</a></li><li><a href="tutorial-static-najax-micro.html">static-najax-micro</a></li><li><a href="tutorial-static-najax.html">static-najax</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="global.html">Global</a></li>
				</ul>
			</li>
			
		</ul>
		<div class="col-sm-3 col-md-3">
            <form class="navbar-form" role="search">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
                    <div class="input-group-btn">
                        <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
                    </div>
                </div>
            </form>
        </div>
	</div>

</div>
</div>


<div class="container" id="toc-content">
<div class="row">

	
	<div class="col-md-12">
	
		<div id="main">
			

		<h1 class="page-title">Source: najax-read.static.js</h1>
    
<section>
    <article>
        <pre
            class="sunlight-highlight-javascript linenums">'use strict';

/**
 * $najax read methods.
 *
 * | Method | Default ver | Tiny ver |
 * |:---|:---:|:---:|
 * | All methods | Yes | Yes |
 *
 * @namespace $najax@read
 * @tutorial najax-read
 *
 * @example
 * $najax.require('sample.js');
 * $najax.require(['s1.js', 's2.js'], {base: 'path/'}).done(function(s1, s2){ ... });
 *
 * $najax.ready(function(){ ... });
 *
 * $najax.load('#target', 'demo.php', {a: 1, b: 2});
 *
 * $najax.module('template.php');
 */

var rqFn = null;

function rqSc(){
	this.data({fn: rqFn});
	rqFn = null;
}

/**
 * Load script and pass &lt;i>function object&lt;/i> by &lt;code>$najax.ready&lt;/code> to arguments.
 *
 * @function require
 * @memberof $najax@read
 *
 * @param {string|array} path Path or Paths.
 * @param {assoc} [opt] Nx options.
 * @param {string} [opt.base=''] Base path.
 * @param {boolean} [opt.run=false] Run script after loading.
 * @param {number} [opt.relaymode=2] For details, see $najax.define.relaymode.
 * @param {boolean} [opt.cache=true] Enable cache.
 * @returns {Linker}
 *
 * @see $najax.ready
 * @see $najax.define.relaymode
 *
 * @see Nx
 * @see Relay
 * @see Linker
 *
 * @tutorial najax-read
 * @example
 * $najax.require('sample.js');
 * $najax.require(['s1.js', 's2.js'], {base: 'path/'}).done(function(s1, s2){ ... });
 * $najax.require(['AClass.js', 'BClass.js']).done(function(AClass, BClass){ ... });
 * $najax.require('sample.js', {run: true});
 */
njx.require = function(path, opt){
	opt = ext({base: '', run: false, relaymode: 2, cache: true}, opt);

	if (typeof path === 'string'){
		path = [path];
	}

	var rls = [];

	for (var i=0;i&lt;path.length;i++){
		rls[i] = njx.script(opt.base + path[i], null, opt).complete(rqSc).done();
	}

	return njx.linker.apply(null, rls).argument(function(rl){
		var f = rl.data('fn');

		if (opt.run &amp;&amp; f){
			f = f();
		}

		return f;
	}).lock();
};

/**
 * Ready function for $najax.require.
 *
 * @function ready
 * @memberof $najax@read
 *
 * @param {function} fn Function.
 *
 * @see $najax.require
 *
 * @tutorial najax-read
 * @example
 * $najax.ready(function(){ ... });
 * $najax.ready($any.makeClass( ... ));
 */
njx.ready = function(fn){
	if (fn){
		rqFn = fn;
	}
};

/**
 * Load template and append HTML and JS to Element. If target Element is null, append to document bottom(auto-append).
 *
 * &lt;b>Specification&lt;/b>&lt;br>
 * Naming in auto-append: &lt;code>prefix + CRC code created by url. Ex: id=njx5690&lt;/code>
 * &lt;code>_elem&lt;/code> by Relay::data is Element.
 *
 * @function load
 * @memberof $najax@read
 *
 * @param {Element} el Element. If null, append automatically as a last Element - auto-append.
 * @param {string} url URL
 * @param {assoc} [vs=null] Parameter
 * @param {assoc} [opt] Nx options.
 * @param {string} [opt.prefix='njx'] When appending to as last Element, it's possible to specify Element's id prefix.
 * @param {number} [opt.relaymode=3] For details, see $najax.define.relaymode.
 * @returns {Linker}
 *
 * @see $najax.module
 * @see $najax.define.relaymode
 * @see Nx
 * @see Relay
 * @see Linker
 *
 * @tutorial najax-read
 * @example
 * $najax.load('#target', 'demo.php', {a: 1, b: 2});
 * $najax.load(null, 'demo.php').done(function(data){ ... });
 */
njx.load = function(el, url, vs, opt){
	opt = ext({prefix: 'njx', relaymode: 3}, opt);
	opt.cache = true;

	if (!el){
		el = document.createElement('div');
		el.id = opt.prefix + $any.crc16(url);
		el.style.display = 'none';
		document.body.appendChild(el);
	}

	opt.element = el;

	var rl = njx.html(url, vs, opt).done();

	if (opt.relaymode &amp; 2){
		rl.data('_elem', el);
	}

	return njx.linker(rl);
};

/**
 * Load module - Wrapper of $najax.load. Append to document bottom.
 *
 * &lt;b>Specification&lt;/b>&lt;br>
 * Append module(HTML and script) to document bottom.
 *
 * @function module
 * @memberof $najax@read
 *
 * @param {string} url URL
 * @param {assoc} [opt] $najax.load options.
 * @returns {Linker}
 *
 * @see $najax.load
 * @see Nx
 * @see Relay
 * @see Linker
 *
 * @tutorial najax-read
 * @example
 * $najax.module('template.php');
 */
njx.module = function(url, opt){
	return njx.load(null, url, null, opt);
};
</pre>
    </article>
</section>





		</div>
	</div>

	<div class="clearfix"></div>

	

</div>
</div>

<div class="modal fade" id="searchResults">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Search results</h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>

<footer>

	&nbsp;


<span class="jsdoc-message">
	Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
	
	using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>

<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>

<script>
$( function () {
	$( "[id*='$']" ).each( function () {
		var $this = $( this );

		$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
	} );

	$( ".tutorial-section pre, .readme-section pre" ).each( function () {
		var $this = $( this );

		var example = $this.find( "code" );
		exampleText = example.html();
		var lang = /{@lang (.*?)}/.exec( exampleText );
		if ( lang && lang[1] ) {
			exampleText = exampleText.replace( lang[0], "" );
			example.html( exampleText );
			lang = lang[1];
		} else {
			var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
			lang = langClassMatch ? langClassMatch[1] : "javascript";
		}

		if ( lang ) {

			$this
			.addClass( "sunlight-highlight-" + lang )
			.addClass( "linenums" )
			.html( example.html() );

		}
	} );

	Sunlight.highlightAll( {
		lineNumbers : true,
		showMenu : true,
		enableDoclinks : true
	} );

	$.catchAnchorLinks( {
        navbarOffset: 10
	} );
	$( "#toc" ).toc( {
		anchorName  : function ( i, heading, prefix ) {
			var id = $( heading ).attr( "id" );
			return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i );
		},
		selectors   : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
		showAndHide : false,
		smoothScrolling: true
	} );

	$( "#main span[id^='toc']" ).addClass( "toc-shim" );
	$( '.dropdown-toggle' ).dropdown();

    $( "table" ).each( function () {
      var $this = $( this );
      $this.addClass('table');
    } );

} );
</script>



<!--Navigation and Symbol Display-->


<!--Google Analytics-->


<script type="text/javascript">
	$(document).ready(function() {
		SearcherDisplay.init();
	});
</script>

</body>
</html>
